<?php
class Login extends Zend_Form
{
    public function init()
    {
    	$this->setAction("/user/login");
    	$this->setMethod("post");

    	$username = new Zend_Form_Element_Text('username', array('id'=>'username'));
    	$username->addFilter('StringTrim')
    			->addFilter('StripTags')
    			->setRequired(true)
    			->setLabel('Логин');

    	$password = new Zend_Form_Element_Password('password');
    	$password->setLabel('Пароль')
    			->addFilter('StringTrim')
    			->addFilter('StripTags')
    			->setRequired(true);

    	$sbmt = new Zend_Form_Element_Submit('login');
    	$sbmt->setLabel('Войти');

    	$this->addElements(array($username, $password, $sbmt));

    	foreach ( $this->getElements() as $element ) {
        	$element->setDecorators(
        		array(
		        	'ViewHelper',
        			'Errors',
		        	array(array('data' => 'HtmlTag'), array('tag' => 'div', 'id' => $element->getId().'-data')),
		        	array(array('label' => 'Label'), array('tag' => 'div', 'escape' => false)),
		        	array(array('row' => 'HtmlTag'), array('tag' => 'div', 'id' => $element->getId().'-element', 'class' => $element->class )),
	        	)
        	);
        }
		$sbmt->setDecorators(array('ViewHelper', array('data'=>'HtmlTag', 'tag'=>'div')));

        $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'div', 'id' => 'login-form')),
            array('Description', array('placement' => 'prepend')),
            'Form'
        ));
    }
}